//
//  DSFriendsRecommendTabController.m
//  budejie
//
//  Created by tangQiang on 8/27/16.
//  Copyright © 2016 Dason. All rights reserved.
//

#import "DSFriendsRecommendTabController.h"
#import "DSFriendsRecommendModel.h"

@interface DSFriendsRecommendTabController ()
/**
 *  数组friendsRecommendModels
 */
@property (strong, nonatomic) NSArray<DSFriendsRecommendModel *> *friendsRecommendModels;

@end

@implementation DSFriendsRecommendTabController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self downloadData];
    
}

#pragma mark - 设置属性FriendsRecommendTabController
- (void)setFriendsRecommendTableVcAllAttributes {
    
}


#pragma mark - 下载数据
- (void)downloadData {
    /**
     *
     *  @param urlstr 暂时不用,用来传递参数的
     *  @param friendsRecommendModels 标签数组
     *  @param error 错误标识
     *
     */
    [DSFriendsRecommendModel downloadDataWithString:nil successBlcok:^(NSArray<DSFriendsRecommendModel *> *friendsRecommendModels) {
        self.friendsRecommendModels = friendsRecommendModels;
        [self.tableView reloadData];
    } failblock:^(NSError *error) {
        if (error) {
            NSLog(@"%@",error);
        }
    }];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    }
    return self.friendsRecommendModels.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FriendsCell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"FriendsCell"];
    }
    if (indexPath.section == 0) {
        cell.textLabel.text = @"推荐";
    } else {
        DSFriendsRecommendModel *friendsRecommendModel = self.friendsRecommendModels[indexPath.row];
        cell.textLabel.text = friendsRecommendModel.name;
    }
    return cell;
}

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        
    } else {
        DSFriendsRecommendModel *friendsRecommendDetailModel = self.friendsRecommendModels[indexPath.row];
        if (self.backMarkID) {
            self.backMarkID(friendsRecommendDetailModel.ID);
        }
    }
}


@end
